package swiper

import (
	"common/json_response"
	"errors"
	"gateway/internal/logic"
	"gateway/internal/types/v1/swiper"
	"github.com/gin-gonic/gin"
	"io"
)

func GetList(ctx *gin.Context) {
	response := json_response.NewJsonHttpResponse(ctx)
	var req swiper.ListRequest
	if err := ctx.ShouldBindJSON(&req); err != nil {
		if !errors.Is(err, io.EOF) {
			response.SetCode(json_response.CODE_ERROR).SetMsg(err.Error()).Send()
			return
		}
	}
	list, err := logic.GetSwiperList(req.Status)
	if err != nil {
		response.SetCode(json_response.CODE_ERROR).SetMsg(err.Error()).Send()
		return
	}
	response.SetCode(json_response.CODE_SUCCESS).SetData(list.List).Send()
	return
}
